﻿var hdnNakedString = $("#hdnNaked").val();
var hdnBundleString = $("#hdnBundle").val();
$(function () {
    //TopBar 
    $("#link_Signup").addClass("current");
    $("#CheckCustomer_true").attr('checked', 'checked');
});
$("#mySignupForm").submit(function (e) {
    if ($(this).valid()) {
        $("#loaderCenter").show();
        $('#screen').css({ 'display': 'block', opacity: 0.3, 'width': $(document).width(), 'height': $(document).height() });
    }
});
$("#CheckCustomer_truefasle").live("click", function (e) {
    $("#divNewCustomer").hide();
    $("#buttonbtn").hide();
    $("#divEverynetAlready").hide();
    $("#divResume").show();

});
$("#CheckCustomer_true").live("click", function (e) {
    $("#divResume").hide();
    $("#divEverynetAlready").hide();
    $("#divNewCustomer").show();
    $("#buttonbtn").show();
});
$("#CheckCustomer_fasle").live("click", function (e) {
    $("#divResume").hide();
    $("#divNewCustomer").hide();
    $("#buttonbtn").hide();
    $("#divEverynetAlready").show();
});

function success(result) {
    if (result.success == -2) {
        $("#logError").html('<ul><li>Invalid Email and Password</li></ul>');

    }
    else if (result.success == -1) {
        $("#logError").html('<ul><li>Your signup registration is completed already.</li></ul>');
    }
    else {
        $("#logError").html('');
        window.location.href = result.url;
    }
}

function successAlready(result) {
    if (result.success == -2) {
        $("#logErrorAlready").html('<ul><li>Invalid Email and Password</li></ul>');

    }
    else if (result.success == -1) {
        $("#logErrorAlready").html('<ul><li>Please first complete your signup process by selecting Resume my application.</li></ul>');
    }
    else {
        $("#logErrorAlready").html('');
        window.location.href = result.url;
    }
}
$(function () {

     if ($.cookie("MainCookie") != null) {
        var chkName = $.cookie("MainCookie").split('|')[2];
        var n = chkName.indexOf(hdnNakedString);
        var n1 = chkName.indexOf(hdnBundleString);
        if (n != -1 || n1 != -1) {
            $('#ServicePhoneNumber').rules('remove', 'required');
            $('#spnServicePhnNum').hide();
        }

    }


    if ($.cookie("UserLoginChk") != null) {
        var chkUsrLogin = $.cookie("UserLoginChk");
        if (chkUsrLogin == 1) {
            $("#divNewCustomer, #buttonbtn, #divEverynetAlready").hide();
            $("#divResume").show();
            $('#CheckCustomer_truefasle').attr('checked', 'checked');
        }
    }
    $("#CheckCustomerType_fasle").removeAttr("disabled");

    //this is used for business
    if ($("#CheckCustomerType_fasle").attr("checked")) {
        $("#divBusiness").show();
    }

});

$("#CheckCustomerType_fasle").live("click", function (e) {
    $("#divBusiness").show();
});

$("#CheckCustomerType_true").live("click", function (e) {
    $("#divBusiness").hide();
    $("#BusinessName").val('');
});